%------------------------------------------------------------
% Author: vjache
% Created: 01.11.2009
% Description: TODO: Add description to pipe_modifier
%------------------------------------------------------------
-module(pipe_modifier).

%------------------------------------------------------------
% Include files
%------------------------------------------------------------
-include("../include/map.hrl").
-include("../include/pipe.hrl").
%------------------------------------------------------------
% Exported Functions
%------------------------------------------------------------
-export([
		 new/1,
		 open/1,
		 push/2,
		 flush/1,
		 close/1]).
%------------------------------------------------------------
% API Functions
%------------------------------------------------------------

new(Handle) ->
	pipe:pipe_from_module(?MODULE, Handle, terminal).

open({Handle,terminal}) -> %%PipeState
    Handle.
push(Handle,?EOF) ->
	Handle;
push(Handle,{put_entry,_Entry={K,V}}) ->
	map:put(Handle,K,V),
	Handle;
push(Handle,{put_entries,Entries}) ->
	map:put_entries(Handle,Entries),
	Handle;
push(Handle,{remove_entry,_Entry={K,V}}) ->
	map:remove_entry(Handle,K,V),
	Handle;
push(Handle,{remove_entries,Entries}) ->
	map:remove_entries(Handle,Entries),
	Handle.


flush(S) ->
	S.
close(_Handle) ->
	ok.

%------------------------------------------------------------
% Local Functions
%------------------------------------------------------------

